﻿Public Class frmHistoryDetails

    Protected dtData As New DataTable

    'GroupKyeNo
    Public wafer_lotno As String = ""
    '組立ロットNo
    Public lot_no As String = ""
    '工程
    Public procCd As String = ""
    '時間
    Public opt_time As String = ""
    '状態
    Public status As String = ""


    Private Sub frmHistryDetails_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load

        'タイトル変更
        Me.Text = "履历详细画面" 'UPD MIAO 2018/8/7

        '画面に値を設定
        txtWaferLotno.Text = wafer_lotno
        txtKeyNo.Text = lot_no
        txtProcCode.Text = procCd
        txtStatus.Text = status

        '行ヘッダー非表示
        DataGridView1.RowHeadersVisible = False
        DataGridView1.AllowUserToAddRows = False

        'l_lotdataよりデータを取得
        dtData = getData()
        If dtData.Rows.Count > 0 Then
            Me.DataGridView1.DataSource = dtData
        End If

    End Sub

    Private Function getData() As DataTable

        Dim szSql As String = ""
        szSql &= " SELECT "
        szSql &= "     COALESCE(B.koumoku_nm, A.mnf_cnd_tag) AS koumoku,  " 'UPD MIAO 2018/10/30
        szSql &= "     A.actual_model "
        szSql &= " FROM "
        szSql &= "     MAT.l_sf_work_rslt_" + procCd + " AS A "
        szSql &= " LEFT JOIN "
        szSql &= "     PER.t_sf_client_item AS B "
        'szSql &= " ON  B.koutei_cd Like A.koutei_cd  || '%' "
        szSql &= " ON (B.koutei_cd = A.koutei_cd OR B.koutei_cd = A.koutei_cd || '_info') "
        szSql &= " AND A.mnf_cnd_tag = B.mnf_cnd_tag "
        szSql &= " WHERE "
        szSql &= "     A.lot_no = ? "
        szSql &= " AND A.koutei_cd = ? "
        szSql &= " AND A.update_time = ? "
        szSql &= " ORDER BY A.mnf_cnd_tag, A.seq "

        Dim dt As DataTable = DBacs.ExecuteSql(szSql, -1, lot_no, procCd, opt_time)
        If IsNothing(dt) Then
            getData = New DataTable
        Else
            getData = dt
        End If
    End Function

End Class